@extends('Admin.layout.blank')
@section('header-css')
<title>会员列表 - 会员管理 - H-ui.admin v3.0</title>
<meta name="keywords" content="H-ui.admin v3.0,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
<meta name="description" content="H-ui.admin v3.0，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
@endsection
@section('body')

<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 订单管理 <span class="c-gray en">&gt;</span> 订单列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="Hui-article">

		<div>
			<div class="pd-20">
				<div class="text-c">
					<form action="{{ route('ordersearch') }}" method="get">
						<input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}'})"
						name="start_date" placeholder="点击日历" id="logmin" class="input-text Wdate" style="width:100px;">
						-
						<input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d'})"
						name="end_date" placeholder="点击日历" id="logmax" class="input-text Wdate" style="width:100px;">
						<input type="number" name="o_num" id="o_num" placeholder="订单编号" style="width:150px" class="input-text">
						<input type="number" name="user_id" id="user_id" placeholder="用户id" style="width:150px" class="input-text">
						<select name="status" style="width:80px;height:28px">
						  <option value="">订单状态</option>
						  <option value="1">待支付</option>
						  <option value="2">已取消</option>
						  <option value="3">超时取消</option>
						  <option value="4">待发货</option>
						  <option value="5">待收货</option>
						  <option value="6">待评价</option>
						  <option value="7">交易完成</option>
						  <option value="8">用户已删除</option>
						</select>
						<button name="" id="search" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜订单</button>
					</form>
				</div>

				<div class="mt-20">
					<table class="table table-border table-bordered table-bg table-hover table-sort" >
						<thead>
							<tr class="text-c">
								<th width="40">订单ID</th>
								<th width="60">用户ID</th>
								<th width="60">订单编号</th>
								<th width="60">收件人</th>
								<th width="60">联系电话</th>
								<th width="100">收件地址</th>
								<th width="30">积分抵扣</th>
								<th width="30">会员折扣</th>
								<th width="40">交易金额</th>
								<th width="40">下单时间</th>
								<th width="40">发货时间</th>
								<th width="40">订单状态</th>
								<th width="40">操作</th>
							</tr>
						</thead>
						<tbody>

							@php
							$statu = [1 => '未支付', 2 => '已取消', 3 => '支付超时，自动取消', 4 => '待发货', 5 => '待收货', 6 => '待评价', 7 => '交易完成', 8 => '用户已删除'];
							@endphp
							@foreach ($orders as $order)
							<tr class="text-c va-m">
								<td>{{ $order->id }}</td>
								<td>{{ $order->user_id }}</td>
								<td>{{ $order->o_num }}</td>
								<td>{{ $order->getname }}</td>
								<td>{{ $order->phone }}</td>
								<td>{{ $order->address }}</td>
								<td>{{ $order->score }}</td>
								<td>{{ $order->discount }}</td>
								<td>{{ $order->total }}</td>

								<td>{{ $order->create_at }}</td>

								<td>@if ($order->status < 4)
									————
									@elseif ($order->send_at == '')
									————
									@endif
									{{ $order->send_at }}
								</td>

								@if ($order->status == 4)
								<td bgcolor="#CC9932">
								@elseif ($order->status == 5)
								<td bgcolor="#F2FC07">
								@else
								<td>
								@endif
									{{ $statu[$order->status] }}</td>

								<td class="td-manage">
									@if ($order->status == 4)
									<a title="发货" href="javascript:;" onclick="order_go(this, {{$order->id}})" class="ml-5" style="text-decoration:none">
										<i class="Hui-iconfont">&#xe603;</i>　|　
									</a>
									@endif
									<a title="详情" href="javascript:;" onclick="order_detail('详情', '{{ route('adminorderdetail', $order->id) }}' ,',','1200','700')" style="text-decoration:none">
										<i class="Hui-iconfont">&#xe720;</i>
									</a>
								</td>
							</tr>
							@endforeach
						</tbody>
					</table>

					{{-- 各种判断心好累 --}}
					@if (!empty($start_date) && !empty($end_date) && !empty($o_num) && !empty($status) && !empty($user_id))
					{{ $orders->appends(['start_date' => $start_date, 'end_date' => $end_date, 'o_num' => $o_num, 'status' => $status, 'user_id' => $user_id])->links() }}

					@elseif (!empty($start_date) && !empty($end_date) && !empty($o_num) && !empty($status))
					{{ $orders->appends(['start_date' => $start_date, 'end_date' => $end_date, 'o_num' => $o_num, 'status' => $status])->links() }}

					@elseif (!empty($end_date) && !empty($o_num) && !empty($status) && !empty($user_id))
					{{ $orders->appends(['end_date' => $end_date, 'o_num' => $o_num, 'status' => $status, 'user_id' => $user_id])->links() }}

					@elseif (!empty($start_date) && !empty($o_num) && !empty($status) && !empty($user_id))
					{{ $orders->appends(['start_date' => $start_date, 'o_num' => $o_num, 'status' => $status, 'user_id' => $user_id])->links() }}

					@elseif (!empty($start_date) && !empty($end_date) && !empty($status) && !empty($user_id))
					{{ $orders->appends(['start_date' => $start_date, 'end_date' => $end_date, 'status' => $status, 'user_id' => $user_id])->links() }}

					@elseif (!empty($start_date) && !empty($end_date) && !empty($o_num) && !empty($user_id))
					{{ $orders->appends(['start_date' => $start_date, 'end_date' => $end_date, 'o_num' => $o_num, 'user_id' => $user_id])->links() }}

					@elseif (!empty($o_num) && !empty($status) && !empty($end_date))
					{{ $orders->appends(['o_num' => $o_num, 'status' => $status, 'end_date' => $end_date])->links() }}

					@elseif (!empty($o_num) && !empty($status) && !empty($start_date))
					{{ $orders->appends(['o_num' => $o_num, 'status' => $status, 'start_date' => $start_date])->links() }}

					@elseif (!empty($end_date) && !empty($status) && !empty($start_date))
					{{ $orders->appends(['end_date' => $end_date, 'status' => $status, 'start_date' => $start_date])->links() }}

					@elseif (!empty($end_date) && !empty($o_num) && !empty($start_date))
					{{ $orders->appends(['end_date' => $end_date, 'o_num' => $o_num, 'start_date' => $start_date])->links() }}

					@elseif (!empty($o_num) && !empty($status) && !empty($user_id))
					{{ $orders->appends(['o_num' => $o_num, 'status' => $status, 'user_id' => $user_id])->links() }}

					@elseif (!empty($end_date) && !empty($status) && !empty($user_id))
					{{ $orders->appends(['end_date' => $end_date, 'status' => $status, 'user_id' => $user_id])->links() }}

					@elseif (!empty($end_date) && !empty($o_num) && !empty($user_id))
					{{ $orders->appends(['end_date' => $end_date, 'o_num' => $o_num, 'user_id' => $user_id])->links() }}

					@elseif (!empty($start_date) && !empty($status) && !empty($user_id))
					{{ $orders->appends(['start_date' => $start_date, 'status' => $status, 'user_id' => $user_id])->links() }}

					@elseif (!empty($start_date) && !empty($o_num) && !empty($user_id))
					{{ $orders->appends(['start_date' => $start_date, 'o_num' => $o_num, 'user_id' => $user_id])->links() }}

					@elseif (!empty($start_date) && !empty($end_date) && !empty($user_id))
					{{ $orders->appends(['start_date' => $start_date, 'end_date' => $end_date, 'user_id' => $user_id])->links() }}

					@elseif (!empty($start_date) && !empty($user_id))
					{{ $orders->appends(['start_date' => $start_date, 'user_id' => $user_id])->links() }}

					@elseif (!empty($end_date) && !empty($user_id))
					{{ $orders->appends(['end_date' => $end_date, 'user_id' => $user_id])->links() }}

					@elseif (!empty($o_num) && !empty($user_id))
					{{ $orders->appends(['o_num' => $o_num, 'user_id' => $user_id])->links() }}

					@elseif (!empty($status) && !empty($user_id))
					{{ $orders->appends(['status' => $status, 'user_id' => $user_id])->links() }}

					@elseif (!empty($start_date) && !empty($end_date))
					{{ $orders->appends(['start_date' => $start_date, 'end_date' => $end_date])->links() }}

					@elseif (!empty($start_date) && !empty($o_num))
					{{ $orders->appends(['start_date' => $start_date, 'o_num' => $o_num])->links() }}

					@elseif (!empty($start_date) && !empty($status))
					{{ $orders->appends(['start_date' => $start_date, 'status' => $status])->links() }}

					@elseif (!empty($o_num) && !empty($end_date))
					{{ $orders->appends(['o_num' => $o_num, 'end_date' => $end_date])->links() }}

					@elseif (!empty($status) && !empty($end_date))
					{{ $orders->appends(['status' => $status, 'end_date' => $end_date])->links() }}

					@elseif (!empty($o_num) && !empty($status))
					{{ $orders->appends(['o_num' => $o_num, 'status' => $status])->links() }}

					@elseif (!empty($start_date))
					{{ $orders->appends(['start_date' => $start_date])->links() }}

					@elseif (!empty($end_date))
					{{ $orders->appends(['end_date' => $end_date])->links() }}

					@elseif (!empty($o_num))
					{{ $orders->appends(['o_num' => $o_num])->links() }}

					@elseif (!empty($status))
					{{ $orders->appends(['status' => $status])->links() }}

					@elseif (!empty($user_id))
					{{ $orders->appends(['user_id' => $user_id])->links() }}

					@else
					{{ $orders->links()  }}
					@endif

				</div>
			</div>
		</div>

	</div>
</section>
@endsection

@section('footer-js')
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="{{ asset('adminPublic/lib/My97DatePicker/4.8/WdatePicker.js') }}"></script>
<script type="text/javascript" src="{{ asset('adminPublic/lib/datatables/1.10.0/jquery.dataTables.min.js') }}"></script>
<script type="text/javascript" src="{{ asset('adminPublic/lib/laypage/1.2/laypage.js') }}"></script>
<script type="text/javascript">

/*订单-详情*/

function order_detail(title,url,id,w,h){
	layer_show(title,url,w,h);
}
$('#search').click(function() {
	console.log($('o_num').val());
});
function order_go(obj,id){
	//此处请求后台程序，下方是成功后的前台处理……
	$.ajax({
		type: 'get',
		dataType: 'json',
		url: '{{ route("ordergo") }}',
		data: 'id=' + id,
		success: function(data) {
			if (data.status == 200) {
				{{-- 发货成功就改表格数据 --}}
				$(obj).parent().prev().text('待收货');
				$(obj).parent().prev().attr('bgcolor', '#F2FC07');
				$(obj).parent().prev().prev().text(data.date);
				layer.msg('已发货!',{icon:1,time:1000});
				$(obj).remove();
			} else {
				//发货失败走这里
				layer.msg('发货失败!',{icon:5,time:1000});
			}
		}
	});
}


</script>
<!--/请在上方写此页面业务相关的脚本-->
@endsection
<!--/请在上方写此页面业务相关的脚本-->
